function f  = new_sj(ini_var,delta_i,x2_i,theta2,v_c,tax_ava_i,FC_i,mc_i,A1_i,mrks_i)% function computing counterfactual price equilibrium  
tax=ini_var(1);

cf_salestax=ones(size(delta_i))*0.19;
tariff_cf=(ones(size(delta_i))*0.35);
tariff_cf(tax_ava_i)=tax;
mc_ii=mc_i.*(1+tariff_cf); 
p_nt_i=ini_var(2:end);
p_cf_i=(p_nt_i.*(1+cf_salestax));

expmu_cf = expmu(theta2,v_c,x2_i,p_cf_i);
expdelta_cf=exp(delta_i);
s_indiv=ind_shares(expdelta_cf,expmu_cf); 
sj_cf=mean(s_indiv,2);
price1=(mc_ii+markup_sim(theta2,v_c,delta_i,s_indiv,A1_i,sj_cf)).*(1+cf_salestax);
expmu_cf2 = expmu(theta2,v_c,x2_i,price1);
s_indiv2=ind_shares(expdelta_cf,expmu_cf2); 
sj_cf2=mean(s_indiv2,2);
sim_i=round(sj_cf2.*mrks_i,0);

st_i=sim_i.*(price1-(price1./(1+cf_salestax)));
tf_i=sim_i.*(mc_ii./(1+tariff_cf)).*tariff_cf;


fc_i=tf_i+st_i;


nsj=abs(sum(FC_i)*100-sum(fc_i)*100);
npj=norm((p_cf_i.*1000)-(price1.*1000));

f=nsj+npj;
end